import {ElMessage} from "element-plus";
import {ref, computed, watchEffect, watch} from 'vue'
import {defineStore} from 'pinia'


export const useChapterStore = defineStore('chapter', () => {
    
    const fontSize = ref(20)
    const main = ref(null)
    const isGreen = ref(false)

    const changeGreen = () => {
      isGreen.value = !isGreen.value
      if (isGreen.value) {
        main.value.style.backgroundColor='#cce8cf'
      } else {
        main.value.style.backgroundColor='#e9faff'
      }
    }

    const init1 = () => {
    
      main.value.style.backgroundColor='#e9faff'
    }


    return {
      fontSize,
      isGreen,
      main,
      changeGreen,
      init1
    }
  },
  {
    persist: {
      key: "chapter",
      storage: localStorage,
      paths:['fontSize','isGreen','isDark'],
      // paths: ["token", "loginUserInfo"],
      serializer: {
        deserialize: JSON.parse,
        serialize: JSON.stringify,
      },
    }
  }
)
